package com.example.fourinarow;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		Button single = (Button) findViewById(R.id.Singel);
		Button multiplayer = (Button) findViewById(R.id.Multiplayer);
		Button statistik = (Button) findViewById(R.id.Statistik);
		Button instruktioner = (Button) findViewById(R.id.Instruktioner);
		Button avsluta = (Button) findViewById(R.id.Avsluta);

		single.setOnClickListener(this);
		multiplayer.setOnClickListener(this);
		statistik.setOnClickListener(this);
		instruktioner.setOnClickListener(this);
		avsluta.setOnClickListener(this);

	}

	@Override
	public void onClick(View v) {
		Class<?> SPGui;
		Class<?> Instructions;
		Class<?> Statistik;

		switch (v.getId()) {

		case R.id.Singel:

			try {
				SPGui = Class.forName("com.example.fourinarow.SPGui");
				Intent it = new Intent(MainActivity.this, SPGui);
				startActivity(it);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
			break;
		case R.id.Multiplayer:
			Intent mpit = new Intent(this, MPlobby.class);
			startActivity(mpit);
			break;
		case R.id.Instruktioner:
			try {
				Instructions = Class
						.forName("com.example.fourinarow.Instructions");
				Intent it = new Intent(MainActivity.this, Instructions);
				startActivity(it);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
			break;

		case R.id.Statistik:
			try {
				Statistik = Class.forName("com.example.fourinarow.DbHandler");
				Intent it = new Intent(MainActivity.this, Statistik);
				startActivity(it);
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
			break;

		case R.id.Avsluta:
			finish();
			System.exit(0);

			break;

		}

	}

}
